getAxisVelocity

open fun getAxisVelocity(@NonNull tracker: VelocityTracker, axis: Int): Float(source)

Equivalent to calling getAxisVelocity for axis and the active pointer.

Return

The previously computed velocity for axis for the active pointer if axis is supported for velocity tracking, or 0 if velocity tracking is not supported for the axis.

Parameters

tracker

The VelocityTracker from which to get axis velocity.

axis

Which axis' velocity to return.

See also


open fun getAxisVelocity(@NonNull tracker: VelocityTracker, axis: Int, pointerId: Int): Float(source)

Retrieve the last computed velocity for a given motion axis. You must first call computeCurrentVelocity or computeCurrentVelocity before calling this function.

In addition to AXIS_X and AXIS_Y which have been supported since the introduction of this class, the following axes can be candidates for this method:

  • AXIS_SCROLL: supported via the platform starting UPSIDE_DOWN_CAKE. Supported via a fallback logic at all platform levels for the active pointer only.

Before accessing velocities of an axis using this method, check that your VelocityTracker instance supports the axis by using isAxisSupported.

Return

The previously computed velocity for axis for pointer ID of id if axis is supported for velocity tracking, or 0 if velocity tracking is not supported for the axis.

Parameters

tracker

The VelocityTracker from which to get axis velocity.

axis

Which axis' velocity to return.

pointerId

Which pointer's velocity to return.

See also